home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc263-src.lha / gcc-2.6.3 / objc-parse.y < prev    next >
GNU Bison Grammar  |  1994-08-27  |  73KB  |  2,698 lines

  1. /* YACC parser for C syntax and for Objective C.  -*-c-*-
  2.    Copyright (C) 1987, 88, 89, 92, 93, 1994 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* This file defines the grammar of C and that of Objective C.
  21.    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  22.    ifc ... end ifc  conditionals contain code for C only.
  23.    Sed commands in Makefile.in are used to convert this file into
  24.    c-parse.y and into objc-parse.y.  */
  25.  
  26. /* To whomever it may concern: I have heard that such a thing was once
  27. written by AT&T, but I have never seen it.  */
  28.  
  29. %expect 22
  30.  
  31. %{
  32. #include <stdio.h>
  33. #include <errno.h>
  34. #include <setjmp.h>
  35.  
  36. #include "config.h"
  37. #include "tree.h"
  38. #include "input.h"
  39. #include "c-lex.h"
  40. #include "c-tree.h"
  41. #include "flags.h"
  42.  
  43. #ifdef MULTIBYTE_CHARS
  44. #include <stdlib.h>
  45. #include <locale.h>
  46. #endif
  47.  
  48. #include "objc-act.h"
  49.  
  50. /* Since parsers are distinct for each language, put the language string
  51.    definition here.  */
  52. char *language_string = "GNU Obj-C";
  53.  
  54. #ifndef errno
  55. extern int errno;
  56. #endif
  57.  
  58. void yyerror ();
  59.  
  60. /* Like YYERROR but do call yyerror.  */
  61. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  62.  
  63. /* Cause the `yydebug' variable to be defined.  */
  64. #define YYDEBUG 1
  65. %}
  66.  
  67. %start program
  68.  
  69. %union {long itype; tree ttype; enum tree_code code;
  70.     char *filename; int lineno; }
  71.  
  72. /* All identifiers that are not reserved words
  73.    and are not declared typedefs in the current block */
  74. %token IDENTIFIER
  75.  
  76. /* All identifiers that are declared typedefs in the current block.
  77.    In some contexts, they are treated just like IDENTIFIER,
  78.    but they can also serve as typespecs in declarations.  */
  79. %token TYPENAME
  80.  
  81. /* Reserved words that specify storage class.
  82.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  83. %token SCSPEC
  84.  
  85. /* Reserved words that specify type.
  86.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  87. %token TYPESPEC
  88.  
  89. /* Reserved words that qualify type: "const" or "volatile".
  90.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  91. %token TYPE_QUAL
  92.  
  93. /* Character or numeric constants.
  94.    yylval is the node for the constant.  */
  95. %token CONSTANT
  96.  
  97. /* String constants in raw form.
  98.    yylval is a STRING_CST node.  */
  99. %token STRING
  100.  
  101. /* "...", used for functions with variable arglists.  */
  102. %token ELLIPSIS
  103.  
  104. /* the reserved words */
  105. /* SCO include files test "ASM", so use something else. */
  106. %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  107. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF ALIGN
  108. %token ATTRIBUTE EXTENSION LABEL
  109. %token REALPART IMAGPART
  110.  
  111. /* Add precedence rules to solve dangling else s/r conflict */
  112. %nonassoc IF
  113. %nonassoc ELSE
  114.  
  115. /* Define the operator tokens and their precedences.
  116.    The value is an integer because, if used, it is the tree code
  117.    to use in the expression made from the operator.  */
  118.  
  119. %right <code> ASSIGN '='
  120. %right <code> '?' ':'
  121. %left <code> OROR
  122. %left <code> ANDAND
  123. %left <code> '|'
  124. %left <code> '^'
  125. %left <code> '&'
  126. %left <code> EQCOMPARE
  127. %left <code> ARITHCOMPARE
  128. %left <code> LSHIFT RSHIFT
  129. %left <code> '+' '-'
  130. %left <code> '*' '/' '%'
  131. %right <code> UNARY PLUSPLUS MINUSMINUS
  132. %left HYPERUNARY
  133. %left <code> POINTSAT '.' '(' '['
  134.  
  135. /* The Objective-C keywords.  These are included in C and in
  136.    Objective C, so that the token codes are the same in both.  */
  137. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  138. %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
  139.  
  140. /* Objective-C string constants in raw form.
  141.    yylval is an OBJC_STRING_CST node.  */
  142. %token OBJC_STRING
  143.  
  144.  
  145. %type <code> unop
  146.  
  147. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  148. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  149. %type <ttype> typed_declspecs reserved_declspecs
  150. %type <ttype> typed_typespecs reserved_typespecquals
  151. %type <ttype> declmods typespec typespecqual_reserved
  152. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  153. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  154. %type <ttype> init maybeasm
  155. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  156. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  157. %type <ttype> any_word
  158.  
  159. %type <ttype> compstmt
  160.  
  161. %type <ttype> declarator
  162. %type <ttype> notype_declarator after_type_declarator
  163. %type <ttype> parm_declarator
  164.  
  165. %type <ttype> structsp component_decl_list component_decl_list2
  166. %type <ttype> component_decl components component_declarator
  167. %type <ttype> enumlist enumerator
  168. %type <ttype> typename absdcl absdcl1 type_quals
  169. %type <ttype> xexpr parms parm identifiers
  170.  
  171. %type <ttype> parmlist parmlist_1 parmlist_2
  172. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  173. %type <ttype> identifiers_or_typenames
  174.  
  175. %type <itype> setspecs
  176.  
  177. %type <filename> save_filename
  178. %type <lineno> save_lineno
  179.  
  180. /* the Objective-C nonterminals */
  181.  
  182. %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
  183. %type <ttype> methoddecl unaryselector keywordselector selector
  184. %type <ttype> keyworddecl receiver objcmessageexpr messageargs
  185. %type <ttype> keywordexpr keywordarglist keywordarg
  186. %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
  187. %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
  188. %type <ttype> objc_string protocolrefs identifier_list objcprotocolexpr
  189. %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
  190.  
  191. %{
  192. /* Number of statements (loosely speaking) seen so far.  */
  193. static int stmt_count;
  194.  
  195. /* Input file and line number of the end of the body of last simple_if;
  196.    used by the stmt-rule immediately after simple_if returns.  */
  197. static char *if_stmt_file;
  198. static int if_stmt_line;
  199.  
  200. /* List of types and structure classes of the current declaration.  */
  201. static tree current_declspecs;
  202.  
  203. /* Stack of saved values of current_declspecs.  */
  204. static tree declspec_stack;
  205.  
  206. /* 1 if we explained undeclared var errors.  */
  207. static int undeclared_variable_notice;
  208.  
  209. /* Objective-C specific information */
  210.  
  211. tree objc_interface_context;
  212. tree objc_implementation_context;
  213. tree objc_method_context;
  214. tree objc_ivar_chain;
  215. tree objc_ivar_context;
  216. enum tree_code objc_inherit_code;
  217. int objc_receiver_context;
  218. int objc_public_flag;
  219.  
  220.  
  221. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  222.  
  223. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  224. extern void yyprint ();
  225. %}
  226.  
  227. %%
  228. program: /* empty */
  229.         { if (pedantic)
  230.             pedwarn ("ANSI C forbids an empty source file");
  231.           objc_finish ();
  232.         }
  233.     | extdefs
  234.         {
  235.           /* In case there were missing closebraces,
  236.              get us back to the global binding level.  */
  237.           while (! global_bindings_p ())
  238.             poplevel (0, 0, 0);
  239.           objc_finish ();
  240.         }
  241.     ;
  242.  
  243. /* the reason for the strange actions in this rule
  244.  is so that notype_initdecls when reached via datadef
  245.  can find a valid list of type and sc specs in $0. */
  246.  
  247. extdefs:
  248.     {$<ttype>$ = NULL_TREE; } extdef
  249.     | extdefs {$<ttype>$ = NULL_TREE; } extdef
  250.     ;
  251.  
  252. extdef:
  253.     fndef
  254.     | datadef
  255.     | objcdef
  256.     | ASM_KEYWORD '(' expr ')' ';'
  257.         { STRIP_NOPS ($3);
  258.           if ((TREE_CODE ($3) == ADDR_EXPR
  259.                && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  260.               || TREE_CODE ($3) == STRING_CST)
  261.             assemble_asm ($3);
  262.           else
  263.             error ("argument of `asm' is not a constant string"); }
  264.     ;
  265.  
  266. datadef:
  267.       setspecs notype_initdecls ';'
  268.         { if (pedantic)
  269.             error ("ANSI C forbids data definition with no type or storage class");
  270.           else if (!flag_traditional)
  271.             warning ("data definition has no type or storage class"); }
  272.         | declmods setspecs notype_initdecls ';'
  273.       {}
  274.     | typed_declspecs setspecs initdecls ';'
  275.       {}
  276.         | declmods ';'
  277.       { pedwarn ("empty declaration"); }
  278.     | typed_declspecs ';'
  279.       { shadow_tag ($1); }
  280.     | error ';'
  281.     | error '}'
  282.     | ';'
  283.         { if (pedantic)
  284.             pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
  285.     ;
  286.  
  287. fndef:
  288.       typed_declspecs setspecs declarator
  289.         { if (! start_function ($1, $3, 0))
  290.             YYERROR1;
  291.           reinit_parse_for_function (); }
  292.       xdecls
  293.         { store_parm_decls (); }
  294.       compstmt_or_error
  295.         { finish_function (0); }
  296.     | typed_declspecs setspecs declarator error
  297.         { }
  298.     | declmods setspecs notype_declarator
  299.         { if (! start_function ($1, $3, 0))
  300.             YYERROR1;
  301.           reinit_parse_for_function (); }
  302.       xdecls
  303.         { store_parm_decls (); }
  304.       compstmt_or_error
  305.         { finish_function (0); }
  306.     | declmods setspecs notype_declarator error
  307.         { }
  308.     | setspecs notype_declarator
  309.         { if (! start_function (NULL_TREE, $2, 0))
  310.             YYERROR1;
  311.           reinit_parse_for_function (); }
  312.       xdecls
  313.         { store_parm_decls (); }
  314.       compstmt_or_error
  315.         { finish_function (0); }
  316.     | setspecs notype_declarator error
  317.         { }
  318.     ;
  319.  
  320. identifier:
  321.     IDENTIFIER
  322.     | TYPENAME
  323.     | OBJECTNAME
  324.         | CLASSNAME
  325.     ;
  326.  
  327. unop:     '&'
  328.         { $$ = ADDR_EXPR; }
  329.     | '-'
  330.         { $$ = NEGATE_EXPR; }
  331.     | '+'
  332.         { $$ = CONVERT_EXPR; }
  333.     | PLUSPLUS
  334.         { $$ = PREINCREMENT_EXPR; }
  335.     | MINUSMINUS
  336.         { $$ = PREDECREMENT_EXPR; }
  337.     | '~'
  338.         { $$ = BIT_NOT_EXPR; }
  339.     | '!'
  340.         { $$ = TRUTH_NOT_EXPR; }
  341.     ;
  342.  
  343. expr:    nonnull_exprlist
  344.         { $$ = build_compound_expr ($1); }
  345.     ;
  346.  
  347. exprlist:
  348.       /* empty */
  349.         { $$ = NULL_TREE; }
  350.     | nonnull_exprlist
  351.     ;
  352.  
  353. nonnull_exprlist:
  354.     expr_no_commas
  355.         { $$ = build_tree_list (NULL_TREE, $1); }
  356.     | nonnull_exprlist ',' expr_no_commas
  357.         { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  358.     ;
  359.  
  360. unary_expr:
  361.     primary
  362.     | '*' cast_expr   %prec UNARY
  363.         { $$ = build_indirect_ref ($2, "unary *"); }
  364.     /* __extension__ turns off -pedantic for following primary.  */
  365.     | EXTENSION
  366.         { $<itype>1 = pedantic;
  367.           pedantic = 0; }
  368.       cast_expr      %prec UNARY
  369.         { $$ = $3;
  370.           pedantic = $<itype>1; }
  371.     | unop cast_expr  %prec UNARY
  372.         { $$ = build_unary_op ($1, $2, 0);
  373.           overflow_warning ($$); }
  374.     /* Refer to the address of a label as a pointer.  */
  375.     | ANDAND identifier
  376.         { tree label = lookup_label ($2);
  377.           if (label == 0)
  378.             $$ = null_pointer_node;
  379.           else
  380.             {
  381.               TREE_USED (label) = 1;
  382.               $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  383.               TREE_CONSTANT ($$) = 1;
  384.             }
  385.         }
  386. /* This seems to be impossible on some machines, so let's turn it off.
  387.    You can use __builtin_next_arg to find the anonymous stack args.
  388.     | '&' ELLIPSIS
  389.         { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
  390.           $$ = error_mark_node;
  391.           if (TREE_VALUE (tree_last (types)) == void_type_node)
  392.             error ("`&...' used in function with fixed number of arguments");
  393.           else
  394.             {
  395.               if (pedantic)
  396.             pedwarn ("ANSI C forbids `&...'");
  397.               $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
  398.               $$ = build_unary_op (ADDR_EXPR, $$, 0);
  399.             } }
  400. */
  401.     | SIZEOF unary_expr  %prec UNARY
  402.         { if (TREE_CODE ($2) == COMPONENT_REF
  403.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  404.             error ("`sizeof' applied to a bit-field");
  405.           $$ = c_sizeof (TREE_TYPE ($2)); }
  406.     | SIZEOF '(' typename ')'  %prec HYPERUNARY
  407.         { $$ = c_sizeof (groktypename ($3)); }
  408.     | ALIGNOF unary_expr  %prec UNARY
  409.         { $$ = c_alignof_expr ($2); }
  410.     | ALIGNOF '(' typename ')'  %prec HYPERUNARY
  411.         { $$ = c_alignof (groktypename ($3)); }
  412.     | REALPART cast_expr %prec UNARY
  413.         { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
  414.     | IMAGPART cast_expr %prec UNARY
  415.         { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
  416.     ;
  417.  
  418. cast_expr:
  419.     unary_expr
  420.     | '(' typename ')' cast_expr  %prec UNARY
  421.         { tree type = groktypename ($2);
  422.           $$ = build_c_cast (type, $4); }
  423.     | '(' typename ')' '{' 
  424.         { start_init (NULL_TREE, NULL, 0);
  425.           $2 = groktypename ($2);
  426.           really_start_incremental_init ($2); }
  427.       initlist_maybe_comma '}'  %prec UNARY
  428.         { char *name;
  429.           tree result = pop_init_level (0);
  430.           tree type = $2;
  431.           finish_init ();
  432.  
  433.           if (pedantic)
  434.             pedwarn ("ANSI C forbids constructor expressions");
  435.           if (TYPE_NAME (type) != 0)
  436.             {
  437.               if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  438.             name = IDENTIFIER_POINTER (TYPE_NAME (type));
  439.               else
  440.             name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  441.             }
  442.           else
  443.             name = "";
  444.           $$ = result;
  445.           if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
  446.             {
  447.               int failure = complete_array_type (type, $$, 1);
  448.               if (failure)
  449.             abort ();
  450.             }
  451.         }
  452.     ;
  453.  
  454. expr_no_commas:
  455.       cast_expr
  456.     | expr_no_commas '+' expr_no_commas
  457.         { $$ = parser_build_binary_op ($2, $1, $3); }
  458.     | expr_no_commas '-' expr_no_commas
  459.         { $$ = parser_build_binary_op ($2, $1, $3); }
  460.     | expr_no_commas '*' expr_no_commas
  461.         { $$ = parser_build_binary_op ($2, $1, $3); }
  462.     | expr_no_commas '/' expr_no_commas
  463.         { $$ = parser_build_binary_op ($2, $1, $3); }
  464.     | expr_no_commas '%' expr_no_commas
  465.         { $$ = parser_build_binary_op ($2, $1, $3); }
  466.     | expr_no_commas LSHIFT expr_no_commas
  467.         { $$ = parser_build_binary_op ($2, $1, $3); }
  468.     | expr_no_commas RSHIFT expr_no_commas
  469.         { $$ = parser_build_binary_op ($2, $1, $3); }
  470.     | expr_no_commas ARITHCOMPARE expr_no_commas
  471.         { $$ = parser_build_binary_op ($2, $1, $3); }
  472.     | expr_no_commas EQCOMPARE expr_no_commas
  473.         { $$ = parser_build_binary_op ($2, $1, $3); }
  474.     | expr_no_commas '&' expr_no_commas
  475.         { $$ = parser_build_binary_op ($2, $1, $3); }
  476.     | expr_no_commas '|' expr_no_commas
  477.         { $$ = parser_build_binary_op ($2, $1, $3); }
  478.     | expr_no_commas '^' expr_no_commas
  479.         { $$ = parser_build_binary_op ($2, $1, $3); }
  480.     | expr_no_commas ANDAND expr_no_commas
  481.         { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
  482.     | expr_no_commas OROR expr_no_commas
  483.         { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
  484.     | expr_no_commas '?' xexpr ':' expr_no_commas
  485.         { $$ = build_conditional_expr ($1, $3, $5); }
  486.     | expr_no_commas '=' expr_no_commas
  487.         { $$ = build_modify_expr ($1, NOP_EXPR, $3);
  488.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  489.     | expr_no_commas ASSIGN expr_no_commas
  490.         { $$ = build_modify_expr ($1, $2, $3);
  491.           /* This inhibits warnings in truthvalue_conversion.  */
  492.           C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
  493.     ;
  494.  
  495. primary:
  496.     IDENTIFIER
  497.         {
  498.           $$ = lastiddecl;
  499.           if (!$$ || $$ == error_mark_node)
  500.             {
  501.               if (yychar == YYEMPTY)
  502.             yychar = YYLEX;
  503.               if (yychar == '(')
  504.             {
  505.               tree decl;
  506.  
  507.               if (objc_receiver_context
  508.                   && ! (objc_receiver_context
  509.                     && strcmp (IDENTIFIER_POINTER ($1), "super")))
  510.                 /* we have a message to super */
  511.                 $$ = get_super_receiver ();
  512.               else if (objc_method_context
  513.                    && (decl = is_ivar (objc_ivar_chain, $1)))
  514.                 {
  515.                   if (is_private (decl))
  516.                 $$ = error_mark_node;
  517.                   else
  518.                 $$ = build_ivar_reference ($1);
  519.                 }
  520.               else
  521.                 {
  522.                   /* Ordinary implicit function declaration.  */
  523.                   $$ = implicitly_declare ($1);
  524.                   assemble_external ($$);
  525.                   TREE_USED ($$) = 1;
  526.                 }
  527.             }
  528.               else if (current_function_decl == 0)
  529.             {
  530.               error ("`%s' undeclared here (not in a function)",
  531.                  IDENTIFIER_POINTER ($1));
  532.               $$ = error_mark_node;
  533.             }
  534.               else
  535.             {
  536.               tree decl;
  537.  
  538.                   if (objc_receiver_context
  539.                   && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
  540.                 /* we have a message to super */
  541.                 $$ = get_super_receiver ();
  542.               else if (objc_method_context
  543.                    && (decl = is_ivar (objc_ivar_chain, $1)))
  544.                 {
  545.                   if (is_private (decl))
  546.                 $$ = error_mark_node;
  547.                   else
  548.                 $$ = build_ivar_reference ($1);
  549.                 }
  550.               else
  551.                 {
  552.                   if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
  553.                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
  554.                 {
  555.                   error ("`%s' undeclared (first use this function)",
  556.                      IDENTIFIER_POINTER ($1));
  557.  
  558.                   if (! undeclared_variable_notice)
  559.                     {
  560.                       error ("(Each undeclared identifier is reported only once");
  561.                       error ("for each function it appears in.)");
  562.                       undeclared_variable_notice = 1;
  563.                     }
  564.                 }
  565.                   $$ = error_mark_node;
  566.                   /* Prevent repeated error messages.  */
  567.                   IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
  568.                   IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
  569.                 }
  570.             }
  571.             }
  572.           else if (TREE_TYPE ($$) == error_mark_node)
  573.             $$ = error_mark_node;
  574.           else if (C_DECL_ANTICIPATED ($$))
  575.             {
  576.               /* The first time we see a build-in function used,
  577.              if it has not been declared.  */
  578.               C_DECL_ANTICIPATED ($$) = 0;
  579.               if (yychar == YYEMPTY)
  580.             yychar = YYLEX;
  581.               if (yychar == '(')
  582.             {
  583.               /* Omit the implicit declaration we
  584.                  would ordinarily do, so we don't lose
  585.                  the actual built in type.
  586.                  But print a diagnostic for the mismatch.  */
  587.               if (objc_method_context
  588.                   && is_ivar (objc_ivar_chain, $1))
  589.                 error ("Instance variable `%s' implicitly declared as function",
  590.                    IDENTIFIER_POINTER (DECL_NAME ($$)));
  591.               else
  592.                 if (TREE_CODE ($$) != FUNCTION_DECL)
  593.                   error ("`%s' implicitly declared as function",
  594.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  595.               else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
  596.                     != TYPE_MODE (integer_type_node))
  597.                    && (TREE_TYPE (TREE_TYPE ($$))
  598.                        != void_type_node))
  599.                 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
  600.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  601.               /* If it really returns void, change that to int.  */
  602.               if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
  603.                 TREE_TYPE ($$)
  604.                   = build_function_type (integer_type_node,
  605.                              TYPE_ARG_TYPES (TREE_TYPE ($$)));
  606.             }
  607.               else
  608.             pedwarn ("built-in function `%s' used without declaration",
  609.                  IDENTIFIER_POINTER (DECL_NAME ($$)));
  610.  
  611.               /* Do what we would ordinarily do when a fn is used.  */
  612.               assemble_external ($$);
  613.               TREE_USED ($$) = 1;
  614.             }
  615.           else
  616.             {
  617.               assemble_external ($$);
  618.               TREE_USED ($$) = 1;
  619.               /* we have a definition - still check if iVariable */
  620.  
  621.               if (!objc_receiver_context
  622.               || (objc_receiver_context
  623.                   && strcmp (IDENTIFIER_POINTER ($1), "super")))
  624.                         {
  625.               tree decl;
  626.  
  627.               if (objc_method_context
  628.                   && (decl = is_ivar (objc_ivar_chain, $1)))
  629.                             {
  630.                               if (IDENTIFIER_LOCAL_VALUE ($1))
  631.                                 warning ("local declaration of `%s' hides instance variable",
  632.                                      IDENTIFIER_POINTER ($1));
  633.                               else
  634.                  {
  635.                    if (is_private (decl))
  636.                      $$ = error_mark_node;
  637.                    else
  638.                      $$ = build_ivar_reference ($1);
  639.                  }
  640.                             }
  641.             }
  642.                       else /* we have a message to super */
  643.                 $$ = get_super_receiver ();
  644.             }
  645.  
  646.           if (TREE_CODE ($$) == CONST_DECL)
  647.             {
  648.               $$ = DECL_INITIAL ($$);
  649.               /* This is to prevent an enum whose value is 0
  650.              from being considered a null pointer constant.  */
  651.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  652.               TREE_CONSTANT ($$) = 1;
  653.             }
  654.         }
  655.     | CONSTANT
  656.     | string
  657.         { $$ = combine_strings ($1); }
  658.     | '(' expr ')'
  659.         { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  660.           if (class == 'e' || class == '1'
  661.               || class == '2' || class == '<')
  662.             C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  663.           $$ = $2; }
  664.     | '(' error ')'
  665.         { $$ = error_mark_node; }
  666.     | '('
  667.         { if (current_function_decl == 0)
  668.             {
  669.               error ("braced-group within expression allowed only inside a function");
  670.               YYERROR;
  671.             }
  672.           /* We must force a BLOCK for this level
  673.              so that, if it is not expanded later,
  674.              there is a way to turn off the entire subtree of blocks
  675.              that are contained in it.  */
  676.           keep_next_level ();
  677.           push_iterator_stack ();
  678.           push_label_level ();
  679.           $<ttype>$ = expand_start_stmt_expr (); }
  680.       compstmt ')'
  681.         { tree rtl_exp;
  682.           if (pedantic)
  683.             pedwarn ("ANSI C forbids braced-groups within expressions");
  684.           pop_iterator_stack ();
  685.           pop_label_level ();
  686.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  687.           /* The statements have side effects, so the group does.  */
  688.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  689.  
  690.           if (TREE_CODE ($3) == BLOCK)
  691.             {
  692.               /* Make a BIND_EXPR for the BLOCK already made.  */
  693.               $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  694.                   NULL_TREE, rtl_exp, $3);
  695.               /* Remove the block from the tree at this point.
  696.              It gets put back at the proper place
  697.              when the BIND_EXPR is expanded.  */
  698.               delete_block ($3);
  699.             }
  700.           else
  701.             $$ = $3;
  702.         }
  703.     | primary '(' exprlist ')'   %prec '.'
  704.         { $$ = build_function_call ($1, $3); }
  705.     | primary '[' expr ']'   %prec '.'
  706.         { $$ = build_array_ref ($1, $3); }
  707.     | primary '.' identifier
  708.         {
  709.                   if (doing_objc_thang)
  710.                     {
  711.               if (is_public ($1, $3))
  712.             $$ = build_component_ref ($1, $3);
  713.               else
  714.             $$ = error_mark_node;
  715.             }
  716.                   else
  717.             $$ = build_component_ref ($1, $3);
  718.         }
  719.     | primary POINTSAT identifier
  720.         {
  721.                   tree expr = build_indirect_ref ($1, "->");
  722.  
  723.                   if (doing_objc_thang)
  724.                     {
  725.               if (is_public (expr, $3))
  726.             $$ = build_component_ref (expr, $3);
  727.               else
  728.             $$ = error_mark_node;
  729.             }
  730.                   else
  731.                     $$ = build_component_ref (expr, $3);
  732.         }
  733.     | primary PLUSPLUS
  734.         { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  735.     | primary MINUSMINUS
  736.         { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  737.     | objcmessageexpr
  738.         { $$ = build_message_expr ($1); }
  739.     | objcselectorexpr
  740.         { $$ = build_selector_expr ($1); }
  741.     | objcprotocolexpr
  742.         { $$ = build_protocol_expr ($1); }
  743.     | objcencodeexpr
  744.         { $$ = build_encode_expr ($1); }
  745.     | objc_string
  746.         { $$ = build_objc_string_object ($1); }
  747.     ;
  748.  
  749. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  750. string:
  751.       STRING
  752.     | string STRING
  753.         { $$ = chainon ($1, $2); }
  754.     ;
  755.  
  756. /* Produces an OBJC_STRING_CST with prehaps more OBJC_STRING_CSTs chained
  757.    onto it.  */
  758. objc_string:
  759.       OBJC_STRING
  760.     | objc_string OBJC_STRING
  761.         { $$ = chainon ($1, $2); }
  762.     ;
  763.  
  764. xdecls:
  765.     /* empty */
  766.     | datadecls
  767.     | datadecls ELLIPSIS
  768.         /* ... is used here to indicate a varargs function.  */
  769.         { c_mark_varargs ();
  770.           if (pedantic)
  771.             pedwarn ("ANSI C does not permit use of `varargs.h'"); }
  772.     ;
  773.  
  774. /* The following are analogous to lineno_decl, decls and decl
  775.    except that they do not allow nested functions.
  776.    They are used for old-style parm decls.  */
  777. lineno_datadecl:
  778.       save_filename save_lineno datadecl
  779.         { }
  780.     ;
  781.  
  782. datadecls:
  783.     lineno_datadecl
  784.     | errstmt
  785.     | datadecls lineno_datadecl
  786.     | lineno_datadecl errstmt
  787.     ;
  788.  
  789. datadecl:
  790.     typed_declspecs setspecs initdecls ';'
  791.         { current_declspecs = TREE_VALUE (declspec_stack);
  792.           declspec_stack = TREE_CHAIN (declspec_stack);
  793.           resume_momentary ($2); }
  794.     | declmods setspecs notype_initdecls ';'
  795.         { current_declspecs = TREE_VALUE (declspec_stack);
  796.           declspec_stack = TREE_CHAIN (declspec_stack);
  797.           resume_momentary ($2); }
  798.     | typed_declspecs ';'
  799.         { shadow_tag_warned ($1, 1);
  800.           pedwarn ("empty declaration"); }
  801.     | declmods ';'
  802.         { pedwarn ("empty declaration"); }
  803.     ;
  804.  
  805. /* This combination which saves a lineno before a decl
  806.    is the normal thing to use, rather than decl itself.
  807.    This is to avoid shift/reduce conflicts in contexts
  808.    where statement labels are allowed.  */
  809. lineno_decl:
  810.       save_filename save_lineno decl
  811.         { }
  812.     ;
  813.  
  814. decls:
  815.     lineno_decl
  816.     | errstmt
  817.     | decls lineno_decl
  818.     | lineno_decl errstmt
  819.     ;
  820.  
  821. /* records the type and storage class specs to use for processing
  822.    the declarators that follow.
  823.    Maintains a stack of outer-level values of current_declspecs,
  824.    for the sake of parm declarations nested in function declarators.  */
  825. setspecs: /* empty */
  826.         { $$ = suspend_momentary ();
  827.           pending_xref_error ();
  828.           declspec_stack = tree_cons (NULL_TREE, current_declspecs,
  829.                           declspec_stack);
  830.           current_declspecs = $<ttype>0; }
  831.     ;
  832.  
  833. decl:
  834.     typed_declspecs setspecs initdecls ';'
  835.         { current_declspecs = TREE_VALUE (declspec_stack);
  836.           declspec_stack = TREE_CHAIN (declspec_stack);
  837.           resume_momentary ($2); }
  838.     | declmods setspecs notype_initdecls ';'
  839.         { current_declspecs = TREE_VALUE (declspec_stack);
  840.           declspec_stack = TREE_CHAIN (declspec_stack);
  841.           resume_momentary ($2); }
  842.     | typed_declspecs setspecs nested_function
  843.         { current_declspecs = TREE_VALUE (declspec_stack);
  844.           declspec_stack = TREE_CHAIN (declspec_stack);
  845.           resume_momentary ($2); }
  846.     | declmods setspecs notype_nested_function
  847.         { current_declspecs = TREE_VALUE (declspec_stack);
  848.           declspec_stack = TREE_CHAIN (declspec_stack);
  849.           resume_momentary ($2); }
  850.     | typed_declspecs ';'
  851.         { shadow_tag ($1); }
  852.     | declmods ';'
  853.         { pedwarn ("empty declaration"); }
  854.     ;
  855.  
  856. /* Declspecs which contain at least one type specifier or typedef name.
  857.    (Just `const' or `volatile' is not enough.)
  858.    A typedef'd name following these is taken as a name to be declared.  */
  859.  
  860. typed_declspecs:
  861.       typespec reserved_declspecs
  862.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  863.     | declmods typespec reserved_declspecs
  864.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  865.     ;
  866.  
  867. reserved_declspecs:  /* empty */
  868.         { $$ = NULL_TREE; }
  869.     | reserved_declspecs typespecqual_reserved
  870.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  871.     | reserved_declspecs SCSPEC
  872.         { if (extra_warnings)
  873.             warning ("`%s' is not at beginning of declaration",
  874.                  IDENTIFIER_POINTER ($2));
  875.           $$ = tree_cons (NULL_TREE, $2, $1); }
  876.     ;
  877.  
  878. /* List of just storage classes and type modifiers.
  879.    A declaration can start with just this, but then it cannot be used
  880.    to redeclare a typedef-name.  */
  881.  
  882. declmods:
  883.       TYPE_QUAL
  884.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  885.           TREE_STATIC ($$) = 1; }
  886.     | SCSPEC
  887.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  888.     | declmods TYPE_QUAL
  889.         { $$ = tree_cons (NULL_TREE, $2, $1);
  890.           TREE_STATIC ($$) = 1; }
  891.     | declmods SCSPEC
  892.         { if (extra_warnings && TREE_STATIC ($1))
  893.             warning ("`%s' is not at beginning of declaration",
  894.                  IDENTIFIER_POINTER ($2));
  895.           $$ = tree_cons (NULL_TREE, $2, $1);
  896.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  897.     ;
  898.  
  899.  
  900. /* Used instead of declspecs where storage classes are not allowed
  901.    (that is, for typenames and structure components).
  902.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  903.  
  904. typed_typespecs:
  905.       typespec reserved_typespecquals
  906.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  907.     | nonempty_type_quals typespec reserved_typespecquals
  908.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  909.     ;
  910.  
  911. reserved_typespecquals:  /* empty */
  912.         { $$ = NULL_TREE; }
  913.     | reserved_typespecquals typespecqual_reserved
  914.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  915.     ;
  916.  
  917. /* A typespec (but not a type qualifier).
  918.    Once we have seen one of these in a declaration,
  919.    if a typedef name appears then it is being redeclared.  */
  920.  
  921. typespec: TYPESPEC
  922.     | structsp
  923.     | TYPENAME
  924.         { /* For a typedef name, record the meaning, not the name.
  925.              In case of `foo foo, bar;'.  */
  926.           $$ = lookup_name ($1); }
  927.     | CLASSNAME protocolrefs
  928.         { $$ = get_static_reference ($1, $2); }
  929.     | OBJECTNAME protocolrefs
  930.         { $$ = get_object_reference ($2); }
  931.     | TYPEOF '(' expr ')'
  932.         { $$ = TREE_TYPE ($3); }
  933.     | TYPEOF '(' typename ')'
  934.         { $$ = groktypename ($3); }
  935.     ;
  936.  
  937. /* A typespec that is a reserved word, or a type qualifier.  */
  938.  
  939. typespecqual_reserved: TYPESPEC
  940.     | TYPE_QUAL
  941.     | structsp
  942.     ;
  943.  
  944. initdecls:
  945.     initdcl
  946.     | initdecls ',' initdcl
  947.     ;
  948.  
  949. notype_initdecls:
  950.     notype_initdcl
  951.     | notype_initdecls ',' initdcl
  952.     ;
  953.  
  954. maybeasm:
  955.       /* empty */
  956.         { $$ = NULL_TREE; }
  957.     | ASM_KEYWORD '(' string ')'
  958.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  959.           $$ = $3;
  960.         }
  961.     ;
  962.  
  963. initdcl:
  964.       declarator maybeasm maybe_attribute '='
  965.         { $<ttype>$ = start_decl ($1, current_declspecs, 1);
  966.           decl_attributes ($<ttype>$, $3);
  967.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  968.       init
  969. /* Note how the declaration of the variable is in effect while its init is parsed! */
  970.         { finish_init ();
  971.           decl_attributes ($<ttype>5, $3);
  972.           finish_decl ($<ttype>5, $6, $2); }
  973.     | declarator maybeasm maybe_attribute
  974.         { tree d = start_decl ($1, current_declspecs, 0);
  975.           decl_attributes (d, $3);
  976.           finish_decl (d, NULL_TREE, $2); }
  977.     ;
  978.  
  979. notype_initdcl:
  980.       notype_declarator maybeasm maybe_attribute '='
  981.         { $<ttype>$ = start_decl ($1, current_declspecs, 1);
  982.           decl_attributes ($<ttype>$, $3);
  983.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  984.       init
  985. /* Note how the declaration of the variable is in effect while its init is parsed! */
  986.         { finish_init ();
  987.           decl_attributes ($<ttype>5, $3);
  988.           finish_decl ($<ttype>5, $6, $2); }
  989.     | notype_declarator maybeasm maybe_attribute
  990.         { tree d = start_decl ($1, current_declspecs, 0);
  991.           decl_attributes (d, $3);
  992.           finish_decl (d, NULL_TREE, $2); }
  993.     ;
  994. /* the * rules are dummies to accept the Apollo extended syntax
  995.    so that the header files compile. */
  996. maybe_attribute:
  997.       /* empty */
  998.           { $$ = NULL_TREE; }
  999.     | attributes
  1000.         { $$ = $1; }
  1001.     ;
  1002.  
  1003. attributes:
  1004.       attribute
  1005.         { $$ = $1; }
  1006.     | attributes attribute
  1007.         { $$ = chainon ($1, $2); }
  1008.     ;
  1009.  
  1010. attribute:
  1011.       ATTRIBUTE '(' '(' attribute_list ')' ')'
  1012.         { $$ = $4; }
  1013.     ;
  1014.  
  1015. attribute_list:
  1016.       attrib
  1017.         { $$ = build_tree_list (NULL_TREE, $1); }
  1018.     | attribute_list ',' attrib
  1019.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  1020.     ;
  1021.  
  1022. attrib:
  1023.     /* empty */
  1024.         { $$ = NULL_TREE; }
  1025.     | any_word
  1026.         { $$ = $1; }
  1027.     | any_word '(' IDENTIFIER ')'
  1028.         { $$ = tree_cons ($1, NULL_TREE,
  1029.                   build_tree_list (NULL_TREE, $3)); }
  1030.     | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  1031.         { $$ = tree_cons ($1, NULL_TREE,
  1032.                   tree_cons (NULL_TREE, $3, $5)); }
  1033.     | any_word '(' nonnull_exprlist ')'
  1034.         { $$ = tree_cons ($1, NULL_TREE, $3); }
  1035.     ;
  1036.  
  1037. /* This still leaves out most reserved keywords,
  1038.    shouldn't we include them?  */
  1039.  
  1040. any_word:
  1041.       identifier
  1042.     | SCSPEC
  1043.     | TYPESPEC
  1044.     | TYPE_QUAL
  1045.     ;
  1046.  
  1047. /* Initializers.  `init' is the entry point.  */
  1048.  
  1049. init:
  1050.     expr_no_commas
  1051.     | '{'
  1052.         { really_start_incremental_init (NULL_TREE);
  1053.           /* Note that the call to clear_momentary
  1054.              is in process_init_element.  */
  1055.           push_momentary (); }
  1056.       initlist_maybe_comma '}'
  1057.         { $$ = pop_init_level (0);
  1058.           if ($$ == error_mark_node
  1059.               && ! (yychar == STRING || yychar == CONSTANT))
  1060.             pop_momentary ();
  1061.           else
  1062.             pop_momentary_nofree (); }
  1063.  
  1064.     | error
  1065.         { $$ = error_mark_node; }
  1066.     ;
  1067.  
  1068. /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
  1069. initlist_maybe_comma:
  1070.       /* empty */
  1071.         { if (pedantic)
  1072.             pedwarn ("ANSI C forbids empty initializer braces"); }
  1073.     | initlist1 maybecomma
  1074.     ;
  1075.  
  1076. initlist1:
  1077.       initelt
  1078.     | initlist1 ',' initelt
  1079.     ;
  1080.  
  1081. /* `initelt' is a single element of an initializer.
  1082.    It may use braces.  */
  1083. initelt:
  1084.     expr_no_commas
  1085.         { process_init_element ($1); }
  1086.     | '{' 
  1087.         { push_init_level (0); }
  1088.       initlist_maybe_comma '}'
  1089.         { process_init_element (pop_init_level (0)); }
  1090.     | error
  1091.     /* These are for labeled elements.  The syntax for an array element
  1092.        initializer conflicts with the syntax for an Objective-C message,
  1093.        so don't include these productions in the Objective-C grammer.  */
  1094.     | identifier ':'
  1095.         { set_init_label ($1); }
  1096.       initelt
  1097.     | '.' identifier '='
  1098.         { set_init_label ($2); }
  1099.       initelt
  1100.     ;
  1101.  
  1102. nested_function:
  1103.       declarator
  1104.         { push_c_function_context ();
  1105.           if (! start_function (current_declspecs, $1, 1))
  1106.             {
  1107.               pop_c_function_context ();
  1108.               YYERROR1;
  1109.             }
  1110.           reinit_parse_for_function ();
  1111.           store_parm_decls (); }
  1112. /* This used to use compstmt_or_error.
  1113.    That caused a bug with input `f(g) int g {}',
  1114.    where the use of YYERROR1 above caused an error
  1115.    which then was handled by compstmt_or_error.
  1116.    There followed a repeated execution of that same rule,
  1117.    which called YYERROR1 again, and so on.  */
  1118.       compstmt
  1119.         { finish_function (1);
  1120.           pop_c_function_context (); }
  1121.     ;
  1122.  
  1123. notype_nested_function:
  1124.       notype_declarator
  1125.         { push_c_function_context ();
  1126.           if (! start_function (current_declspecs, $1, 1))
  1127.             {
  1128.               pop_c_function_context ();
  1129.               YYERROR1;
  1130.             }
  1131.           reinit_parse_for_function ();
  1132.           store_parm_decls (); }
  1133. /* This used to use compstmt_or_error.
  1134.    That caused a bug with input `f(g) int g {}',
  1135.    where the use of YYERROR1 above caused an error
  1136.    which then was handled by compstmt_or_error.
  1137.    There followed a repeated execution of that same rule,
  1138.    which called YYERROR1 again, and so on.  */
  1139.       compstmt
  1140.         { finish_function (1);
  1141.           pop_c_function_context (); }
  1142.     ;
  1143.  
  1144. /* Any kind of declarator (thus, all declarators allowed
  1145.    after an explicit typespec).  */
  1146.  
  1147. declarator:
  1148.       after_type_declarator
  1149.     | notype_declarator
  1150.     ;
  1151.  
  1152. /* A declarator that is allowed only after an explicit typespec.  */
  1153.  
  1154. after_type_declarator:
  1155.       '(' after_type_declarator ')'
  1156.         { $$ = $2; }
  1157.     | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
  1158.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1159. /*    | after_type_declarator '(' error ')'  %prec '.'
  1160.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1161.           poplevel (0, 0, 0); }  */
  1162.     | after_type_declarator '[' expr ']'  %prec '.'
  1163.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1164.     | after_type_declarator '[' ']'  %prec '.'
  1165.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1166.     | '*' type_quals after_type_declarator  %prec UNARY
  1167.         { $$ = make_pointer_declarator ($2, $3); }
  1168.     | TYPENAME
  1169.     | OBJECTNAME
  1170.     ;
  1171.  
  1172. /* Kinds of declarator that can appear in a parameter list
  1173.    in addition to notype_declarator.  This is like after_type_declarator
  1174.    but does not allow a typedef name in parentheses as an identifier
  1175.    (because it would conflict with a function with that typedef as arg).  */
  1176.  
  1177. parm_declarator:
  1178.       parm_declarator '(' parmlist_or_identifiers  %prec '.'
  1179.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1180. /*    | parm_declarator '(' error ')'  %prec '.'
  1181.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1182.           poplevel (0, 0, 0); }  */
  1183.     | parm_declarator '[' expr ']'  %prec '.'
  1184.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1185.     | parm_declarator '[' ']'  %prec '.'
  1186.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1187.     | '*' type_quals parm_declarator  %prec UNARY
  1188.         { $$ = make_pointer_declarator ($2, $3); }
  1189.     | TYPENAME
  1190.     ;
  1191.  
  1192. /* A declarator allowed whether or not there has been
  1193.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  1194.  
  1195. notype_declarator:
  1196.       notype_declarator '(' parmlist_or_identifiers  %prec '.'
  1197.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1198. /*    | notype_declarator '(' error ')'  %prec '.'
  1199.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1200.           poplevel (0, 0, 0); }  */
  1201.     | '(' notype_declarator ')'
  1202.         { $$ = $2; }
  1203.     | '*' type_quals notype_declarator  %prec UNARY
  1204.         { $$ = make_pointer_declarator ($2, $3); }
  1205.     | notype_declarator '[' expr ']'  %prec '.'
  1206.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1207.     | notype_declarator '[' ']'  %prec '.'
  1208.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1209.     | IDENTIFIER
  1210.     ;
  1211.  
  1212. structsp:
  1213.       STRUCT identifier '{'
  1214.         { $$ = start_struct (RECORD_TYPE, $2);
  1215.           /* Start scope of tag before parsing components.  */
  1216.         }
  1217.       component_decl_list '}'
  1218.         { $$ = finish_struct ($<ttype>4, $5);
  1219.           /* Really define the structure.  */
  1220.         }
  1221.     | STRUCT '{' component_decl_list '}'
  1222.         { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1223.                       $3); }
  1224.     | STRUCT identifier
  1225.         { $$ = xref_tag (RECORD_TYPE, $2); }
  1226.     | UNION identifier '{'
  1227.         { $$ = start_struct (UNION_TYPE, $2); }
  1228.       component_decl_list '}'
  1229.         { $$ = finish_struct ($<ttype>4, $5); }
  1230.     | UNION '{' component_decl_list '}'
  1231.         { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1232.                       $3); }
  1233.     | UNION identifier
  1234.         { $$ = xref_tag (UNION_TYPE, $2); }
  1235.     | ENUM identifier '{'
  1236.         { $<itype>3 = suspend_momentary ();
  1237.           $$ = start_enum ($2); }
  1238.       enumlist maybecomma_warn '}'
  1239.         { $$ = finish_enum ($<ttype>4, nreverse ($5));
  1240.           resume_momentary ($<itype>3); }
  1241.     | ENUM '{'
  1242.         { $<itype>2 = suspend_momentary ();
  1243.           $$ = start_enum (NULL_TREE); }
  1244.       enumlist maybecomma_warn '}'
  1245.         { $$ = finish_enum ($<ttype>3, nreverse ($4));
  1246.           resume_momentary ($<itype>2); }
  1247.     | ENUM identifier
  1248.         { $$ = xref_tag (ENUMERAL_TYPE, $2); }
  1249.     ;
  1250.  
  1251. maybecomma:
  1252.       /* empty */
  1253.     | ','
  1254.     ;
  1255.  
  1256. maybecomma_warn:
  1257.       /* empty */
  1258.     | ','
  1259.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  1260.     ;
  1261.  
  1262. component_decl_list:
  1263.       component_decl_list2
  1264.         { $$ = $1; }
  1265.     | component_decl_list2 component_decl
  1266.         { $$ = chainon ($1, $2);
  1267.           pedwarn ("no semicolon at end of struct or union"); }
  1268.     ;
  1269.  
  1270. component_decl_list2:    /* empty */
  1271.         { $$ = NULL_TREE; }
  1272.     | component_decl_list2 component_decl ';'
  1273.         { $$ = chainon ($1, $2); }
  1274.     | component_decl_list2 ';'
  1275.         { if (pedantic)
  1276.             pedwarn ("extra semicolon in struct or union specified"); }
  1277.     /* foo(sizeof(struct{ @defs(ClassName)})); */
  1278.     | DEFS '(' CLASSNAME ')'
  1279.         {
  1280.           tree interface = lookup_interface ($3);
  1281.  
  1282.           if (interface)
  1283.             $$ = get_class_ivars (interface);
  1284.           else
  1285.             {
  1286.               error ("Cannot find interface declaration for `%s'",
  1287.                  IDENTIFIER_POINTER ($3));
  1288.               $$ = NULL_TREE;
  1289.             }
  1290.         }
  1291.     ;
  1292.  
  1293. /* There is a shift-reduce conflict here, because `components' may
  1294.    start with a `typename'.  It happens that shifting (the default resolution)
  1295.    does the right thing, because it treats the `typename' as part of
  1296.    a `typed_typespecs'.
  1297.  
  1298.    It is possible that this same technique would allow the distinction
  1299.    between `notype_initdecls' and `initdecls' to be eliminated.
  1300.    But I am being cautious and not trying it.  */
  1301.  
  1302. component_decl:
  1303.       typed_typespecs setspecs components
  1304.         { $$ = $3;
  1305.           current_declspecs = TREE_VALUE (declspec_stack);
  1306.           declspec_stack = TREE_CHAIN (declspec_stack);
  1307.           resume_momentary ($2); }
  1308.     | typed_typespecs
  1309.         { if (pedantic)
  1310.             pedwarn ("ANSI C forbids member declarations with no members");
  1311.           shadow_tag($1);
  1312.           $$ = NULL_TREE; }
  1313.     | nonempty_type_quals setspecs components
  1314.         { $$ = $3;
  1315.           current_declspecs = TREE_VALUE (declspec_stack);
  1316.           declspec_stack = TREE_CHAIN (declspec_stack);
  1317.           resume_momentary ($2); }
  1318.     | nonempty_type_quals
  1319.         { if (pedantic)
  1320.             pedwarn ("ANSI C forbids member declarations with no members");
  1321.           shadow_tag($1);
  1322.           $$ = NULL_TREE; }
  1323.     | error
  1324.         { $$ = NULL_TREE; }
  1325.     ;
  1326.  
  1327. components:
  1328.       component_declarator
  1329.     | components ',' component_declarator
  1330.         { $$ = chainon ($1, $3); }
  1331.     ;
  1332.  
  1333. component_declarator:
  1334.       save_filename save_lineno declarator maybe_attribute
  1335.         { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1336.           decl_attributes ($$, $4); }
  1337.     | save_filename save_lineno
  1338.       declarator ':' expr_no_commas maybe_attribute
  1339.         { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1340.           decl_attributes ($$, $6); }
  1341.     | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1342.         { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1343.           decl_attributes ($$, $5); }
  1344.     ;
  1345.  
  1346. /* We chain the enumerators in reverse order.
  1347.    They are put in forward order where enumlist is used.
  1348.    (The order used to be significant, but no longer is so.
  1349.    However, we still maintain the order, just to be clean.)  */
  1350.  
  1351. enumlist:
  1352.       enumerator
  1353.     | enumlist ',' enumerator
  1354.         { $$ = chainon ($3, $1); }
  1355.     | error
  1356.         { $$ = error_mark_node; }
  1357.     ;
  1358.  
  1359.  
  1360. enumerator:
  1361.       identifier
  1362.         { $$ = build_enumerator ($1, NULL_TREE); }
  1363.     | identifier '=' expr_no_commas
  1364.         { $$ = build_enumerator ($1, $3); }
  1365.     ;
  1366.  
  1367. typename:
  1368.     typed_typespecs absdcl
  1369.         { $$ = build_tree_list ($1, $2); }
  1370.     | nonempty_type_quals absdcl
  1371.         { $$ = build_tree_list ($1, $2); }
  1372.     ;
  1373.  
  1374. absdcl:   /* an absolute declarator */
  1375.     /* empty */
  1376.         { $$ = NULL_TREE; }
  1377.     | absdcl1
  1378.     ;
  1379.  
  1380. nonempty_type_quals:
  1381.       TYPE_QUAL
  1382.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1383.     | nonempty_type_quals TYPE_QUAL
  1384.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1385.     ;
  1386.  
  1387. type_quals:
  1388.       /* empty */
  1389.         { $$ = NULL_TREE; }
  1390.     | type_quals TYPE_QUAL
  1391.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1392.     ;
  1393.  
  1394. absdcl1:  /* a nonempty absolute declarator */
  1395.       '(' absdcl1 ')'
  1396.         { $$ = $2; }
  1397.       /* `(typedef)1' is `int'.  */
  1398.     | '*' type_quals absdcl1  %prec UNARY
  1399.         { $$ = make_pointer_declarator ($2, $3); }
  1400.     | '*' type_quals  %prec UNARY
  1401.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1402.     | absdcl1 '(' parmlist  %prec '.'
  1403.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1404.     | absdcl1 '[' expr ']'  %prec '.'
  1405.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1406.     | absdcl1 '[' ']'  %prec '.'
  1407.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1408.     | '(' parmlist  %prec '.'
  1409.         { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1410.     | '[' expr ']'  %prec '.'
  1411.         { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
  1412.     | '[' ']'  %prec '.'
  1413.         { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
  1414.     ;
  1415.  
  1416. /* at least one statement, the first of which parses without error.  */
  1417. /* stmts is used only after decls, so an invalid first statement
  1418.    is actually regarded as an invalid decl and part of the decls.  */
  1419.  
  1420. stmts:
  1421.       lineno_stmt_or_label
  1422.     | stmts lineno_stmt_or_label
  1423.     | stmts errstmt
  1424.     ;
  1425.  
  1426. xstmts:
  1427.     /* empty */
  1428.     | stmts
  1429.     ;
  1430.  
  1431. errstmt:  error ';'
  1432.     ;
  1433.  
  1434. pushlevel:  /* empty */
  1435.         { emit_line_note (input_filename, lineno);
  1436.           pushlevel (0);
  1437.           clear_last_expr ();
  1438.           push_momentary ();
  1439.           expand_start_bindings (0);
  1440.           if (objc_method_context)
  1441.             add_objc_decls ();
  1442.         }
  1443.     ;
  1444.  
  1445. /* Read zero or more forward-declarations for labels
  1446.    that nested functions can jump to.  */
  1447. maybe_label_decls:
  1448.       /* empty */
  1449.     | label_decls
  1450.         { if (pedantic)
  1451.             pedwarn ("ANSI C forbids label declarations"); }
  1452.     ;
  1453.  
  1454. label_decls:
  1455.       label_decl
  1456.     | label_decls label_decl
  1457.     ;
  1458.  
  1459. label_decl:
  1460.       LABEL identifiers_or_typenames ';'
  1461.         { tree link;
  1462.           for (link = $2; link; link = TREE_CHAIN (link))
  1463.             {
  1464.               tree label = shadow_label (TREE_VALUE (link));
  1465.               C_DECLARED_LABEL_FLAG (label) = 1;
  1466.               declare_nonlocal_label (label);
  1467.             }
  1468.         }
  1469.     ;
  1470.  
  1471. /* This is the body of a function definition.
  1472.    It causes syntax errors to ignore to the next openbrace.  */
  1473. compstmt_or_error:
  1474.       compstmt
  1475.         {}
  1476.     | error compstmt
  1477.     ;
  1478.  
  1479. compstmt: '{' '}'
  1480.         { $$ = convert (void_type_node, integer_zero_node); }
  1481.     | '{' pushlevel maybe_label_decls decls xstmts '}'
  1482.         { emit_line_note (input_filename, lineno);
  1483.           expand_end_bindings (getdecls (), 1, 0);
  1484.           $$ = poplevel (1, 1, 0);
  1485.           if (yychar == CONSTANT || yychar == STRING)
  1486.             pop_momentary_nofree ();
  1487.           else
  1488.             pop_momentary (); }
  1489.     | '{' pushlevel maybe_label_decls error '}'
  1490.         { emit_line_note (input_filename, lineno);
  1491.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1492.           $$ = poplevel (kept_level_p (), 0, 0);
  1493.           if (yychar == CONSTANT || yychar == STRING)
  1494.             pop_momentary_nofree ();
  1495.           else
  1496.             pop_momentary (); }
  1497.     | '{' pushlevel maybe_label_decls stmts '}'
  1498.         { emit_line_note (input_filename, lineno);
  1499.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1500.           $$ = poplevel (kept_level_p (), 0, 0);
  1501.           if (yychar == CONSTANT || yychar == STRING)
  1502.             pop_momentary_nofree ();
  1503.           else
  1504.             pop_momentary (); }
  1505.     ;
  1506.  
  1507. /* Value is number of statements counted as of the closeparen.  */
  1508. simple_if:
  1509.       if_prefix lineno_labeled_stmt
  1510. /* Make sure expand_end_cond is run once
  1511.    for each call to expand_start_cond.
  1512.    Otherwise a crash is likely.  */
  1513.     | if_prefix error
  1514.     ;
  1515.  
  1516. if_prefix:
  1517.       IF '(' expr ')'
  1518.         { emit_line_note ($<filename>-1, $<lineno>0);
  1519.           expand_start_cond (truthvalue_conversion ($3), 0);
  1520.           $<itype>$ = stmt_count;
  1521.           if_stmt_file = $<filename>-1;
  1522.           if_stmt_line = $<lineno>0;
  1523.           position_after_white_space (); }
  1524.     ;
  1525.  
  1526. /* This is a subroutine of stmt.
  1527.    It is used twice, once for valid DO statements
  1528.    and once for catching errors in parsing the end test.  */
  1529. do_stmt_start:
  1530.       DO
  1531.         { stmt_count++;
  1532.           emit_line_note ($<filename>-1, $<lineno>0);
  1533.           /* See comment in `while' alternative, above.  */
  1534.           emit_nop ();
  1535.           expand_start_loop_continue_elsewhere (1);
  1536.           position_after_white_space (); }
  1537.       lineno_labeled_stmt WHILE
  1538.         { expand_loop_continue_here (); }
  1539.     ;
  1540.  
  1541. save_filename:
  1542.         { $$ = input_filename; }
  1543.     ;
  1544.  
  1545. save_lineno:
  1546.         { $$ = lineno; }
  1547.     ;
  1548.  
  1549. lineno_labeled_stmt:
  1550.       save_filename save_lineno stmt
  1551.         { }
  1552. /*    | save_filename save_lineno error
  1553.         { }
  1554. */
  1555.     | save_filename save_lineno label lineno_labeled_stmt
  1556.         { }
  1557.     ;
  1558.  
  1559. lineno_stmt_or_label:
  1560.       save_filename save_lineno stmt_or_label
  1561.         { }
  1562.     ;
  1563.  
  1564. stmt_or_label:
  1565.       stmt
  1566.     | label
  1567.         { int next;
  1568.           position_after_white_space ();
  1569.           next = getc (finput);
  1570.           ungetc (next, finput);
  1571.           if (pedantic && next == '}')
  1572.             pedwarn ("ANSI C forbids label at end of compound statement");
  1573.         }
  1574.     ;
  1575.  
  1576. /* Parse a single real statement, not including any labels.  */
  1577. stmt:
  1578.       compstmt
  1579.         { stmt_count++; }
  1580.         | all_iter_stmt 
  1581.     | expr ';'
  1582.         { stmt_count++;
  1583.           emit_line_note ($<filename>-1, $<lineno>0);
  1584. /* It appears that this should not be done--that a non-lvalue array
  1585.    shouldn't get an error if the value isn't used.
  1586.    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
  1587.    if it appears as a top-level expression,
  1588.    but says nothing about non-lvalue arrays.  */
  1589. #if 0
  1590.           /* Call default_conversion to get an error
  1591.              on referring to a register array if pedantic.  */
  1592.           if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
  1593.               || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
  1594.             $1 = default_conversion ($1);
  1595. #endif
  1596.           iterator_expand ($1);
  1597.           clear_momentary (); }
  1598.     | simple_if ELSE
  1599.         { expand_start_else ();
  1600.           $<itype>1 = stmt_count;
  1601.           position_after_white_space (); }
  1602.       lineno_labeled_stmt
  1603.         { expand_end_cond ();
  1604.           if (extra_warnings && stmt_count == $<itype>1)
  1605.             warning ("empty body in an else-statement"); }
  1606.     | simple_if %prec IF
  1607.         { expand_end_cond ();
  1608.           /* This warning is here instead of in simple_if, because we
  1609.              do not want a warning if an empty if is followed by an
  1610.              else statement.  Increment stmt_count so we don't
  1611.              give a second error if this is a nested `if'.  */
  1612.           if (extra_warnings && stmt_count++ == $<itype>1)
  1613.             warning_with_file_and_line (if_stmt_file, if_stmt_line,
  1614.                         "empty body in an if-statement"); }
  1615. /* Make sure expand_end_cond is run once
  1616.    for each call to expand_start_cond.
  1617.    Otherwise a crash is likely.  */
  1618.     | simple_if ELSE error
  1619.         { expand_end_cond (); }
  1620.     | WHILE
  1621.         { stmt_count++;
  1622.           emit_line_note ($<filename>-1, $<lineno>0);
  1623.           /* The emit_nop used to come before emit_line_note,
  1624.              but that made the nop seem like part of the preceding line.
  1625.              And that was confusing when the preceding line was
  1626.              inside of an if statement and was not really executed.
  1627.              I think it ought to work to put the nop after the line number.
  1628.              We will see.  --rms, July 15, 1991.  */
  1629.           emit_nop (); }
  1630.       '(' expr ')'
  1631.         { /* Don't start the loop till we have succeeded
  1632.              in parsing the end test.  This is to make sure
  1633.              that we end every loop we start.  */
  1634.           expand_start_loop (1);
  1635.           emit_line_note (input_filename, lineno);
  1636.           expand_exit_loop_if_false (NULL_PTR,
  1637.                          truthvalue_conversion ($4));
  1638.           position_after_white_space (); }
  1639.       lineno_labeled_stmt
  1640.         { expand_end_loop (); }
  1641.     | do_stmt_start
  1642.       '(' expr ')' ';'
  1643.         { emit_line_note (input_filename, lineno);
  1644.           expand_exit_loop_if_false (NULL_PTR,
  1645.                          truthvalue_conversion ($3));
  1646.           expand_end_loop ();
  1647.           clear_momentary (); }
  1648. /* This rule is needed to make sure we end every loop we start.  */
  1649.     | do_stmt_start error
  1650.         { expand_end_loop ();
  1651.           clear_momentary (); }
  1652.     | FOR
  1653.       '(' xexpr ';'
  1654.         { stmt_count++;
  1655.           emit_line_note ($<filename>-1, $<lineno>0);
  1656.           /* See comment in `while' alternative, above.  */
  1657.           emit_nop ();
  1658.           if ($3) c_expand_expr_stmt ($3);
  1659.           /* Next step is to call expand_start_loop_continue_elsewhere,
  1660.              but wait till after we parse the entire for (...).
  1661.              Otherwise, invalid input might cause us to call that
  1662.              fn without calling expand_end_loop.  */
  1663.         }
  1664.       xexpr ';'
  1665.         /* Can't emit now; wait till after expand_start_loop...  */
  1666.         { $<lineno>7 = lineno;
  1667.           $<filename>$ = input_filename; }
  1668.       xexpr ')'
  1669.         { 
  1670.           /* Start the loop.  Doing this after parsing
  1671.              all the expressions ensures we will end the loop.  */
  1672.           expand_start_loop_continue_elsewhere (1);
  1673.           /* Emit the end-test, with a line number.  */
  1674.           emit_line_note ($<filename>8, $<lineno>7);
  1675.           if ($6)
  1676.             expand_exit_loop_if_false (NULL_PTR,
  1677.                            truthvalue_conversion ($6));
  1678.           /* Don't let the tree nodes for $9 be discarded by
  1679.              clear_momentary during the parsing of the next stmt.  */
  1680.           push_momentary ();
  1681.           $<lineno>7 = lineno;
  1682.           $<filename>8 = input_filename;
  1683.           position_after_white_space (); }
  1684.       lineno_labeled_stmt
  1685.         { /* Emit the increment expression, with a line number.  */
  1686.           emit_line_note ($<filename>8, $<lineno>7);
  1687.           expand_loop_continue_here ();
  1688.           if ($9)
  1689.             c_expand_expr_stmt ($9);
  1690.           if (yychar == CONSTANT || yychar == STRING)
  1691.             pop_momentary_nofree ();
  1692.           else
  1693.             pop_momentary ();
  1694.           expand_end_loop (); }
  1695.     | SWITCH '(' expr ')'
  1696.         { stmt_count++;
  1697.           emit_line_note ($<filename>-1, $<lineno>0);
  1698.           c_expand_start_case ($3);
  1699.           /* Don't let the tree nodes for $3 be discarded by
  1700.              clear_momentary during the parsing of the next stmt.  */
  1701.           push_momentary ();
  1702.           position_after_white_space (); }
  1703.       lineno_labeled_stmt
  1704.         { expand_end_case ($3);
  1705.           if (yychar == CONSTANT || yychar == STRING)
  1706.             pop_momentary_nofree ();
  1707.           else
  1708.             pop_momentary (); }
  1709.     | BREAK ';'
  1710.         { stmt_count++;
  1711.           emit_line_note ($<filename>-1, $<lineno>0);
  1712.           if ( ! expand_exit_something ())
  1713.             error ("break statement not within loop or switch"); }
  1714.     | CONTINUE ';'
  1715.         { stmt_count++;
  1716.           emit_line_note ($<filename>-1, $<lineno>0);
  1717.           if (! expand_continue_loop (NULL_PTR))
  1718.             error ("continue statement not within a loop"); }
  1719.     | RETURN ';'
  1720.         { stmt_count++;
  1721.           emit_line_note ($<filename>-1, $<lineno>0);
  1722.           c_expand_return (NULL_TREE); }
  1723.     | RETURN expr ';'
  1724.         { stmt_count++;
  1725.           emit_line_note ($<filename>-1, $<lineno>0);
  1726.           c_expand_return ($2); }
  1727.     | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  1728.         { stmt_count++;
  1729.           emit_line_note ($<filename>-1, $<lineno>0);
  1730.           STRIP_NOPS ($4);
  1731.           if ((TREE_CODE ($4) == ADDR_EXPR
  1732.                && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
  1733.               || TREE_CODE ($4) == STRING_CST)
  1734.             expand_asm ($4);
  1735.           else
  1736.             error ("argument of `asm' is not a constant string"); }
  1737.     /* This is the case with just output operands.  */
  1738.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  1739.         { stmt_count++;
  1740.           emit_line_note ($<filename>-1, $<lineno>0);
  1741.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  1742.                      $2 == ridpointers[(int)RID_VOLATILE],
  1743.                      input_filename, lineno); }
  1744.     /* This is the case with input operands as well.  */
  1745.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  1746.         { stmt_count++;
  1747.           emit_line_note ($<filename>-1, $<lineno>0);
  1748.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  1749.                      $2 == ridpointers[(int)RID_VOLATILE],
  1750.                      input_filename, lineno); }
  1751.     /* This is the case with clobbered registers as well.  */
  1752.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  1753.         asm_operands ':' asm_clobbers ')' ';'
  1754.         { stmt_count++;
  1755.           emit_line_note ($<filename>-1, $<lineno>0);
  1756.           c_expand_asm_operands ($4, $6, $8, $10,
  1757.                      $2 == ridpointers[(int)RID_VOLATILE],
  1758.                      input_filename, lineno); }
  1759.     | GOTO identifier ';'
  1760.         { tree decl;
  1761.           stmt_count++;
  1762.           emit_line_note ($<filename>-1, $<lineno>0);
  1763.           decl = lookup_label ($2);
  1764.           if (decl != 0)
  1765.             {
  1766.               TREE_USED (decl) = 1;
  1767.               expand_goto (decl);
  1768.             }
  1769.         }
  1770.     | GOTO '*' expr ';'
  1771.         { stmt_count++;
  1772.           emit_line_note ($<filename>-1, $<lineno>0);
  1773.           expand_computed_goto (convert (ptr_type_node, $3)); }
  1774.     | ';'
  1775.     ;
  1776.  
  1777. all_iter_stmt:
  1778.       all_iter_stmt_simple
  1779. /*    | all_iter_stmt_with_decl */
  1780.     ;
  1781.  
  1782. all_iter_stmt_simple:
  1783.       FOR '(' primary ')' 
  1784.       {
  1785.         /* The value returned by this action is  */
  1786.         /*      1 if everything is OK */ 
  1787.         /*      0 in case of error or already bound iterator */
  1788.  
  1789.         $<itype>$ = 0;
  1790.         if (TREE_CODE ($3) != VAR_DECL)
  1791.           error ("invalid `for (ITERATOR)' syntax");
  1792.         else if (! ITERATOR_P ($3))
  1793.           error ("`%s' is not an iterator",
  1794.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1795.         else if (ITERATOR_BOUND_P ($3))
  1796.           error ("`for (%s)' inside expansion of same iterator",
  1797.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1798.         else
  1799.           {
  1800.         $<itype>$ = 1;
  1801.         iterator_for_loop_start ($3);
  1802.           }
  1803.       }
  1804.       lineno_labeled_stmt
  1805.       {
  1806.         if ($<itype>5)
  1807.           iterator_for_loop_end ($3);
  1808.       }
  1809.  
  1810. /*  This really should allow any kind of declaration,
  1811.     for generality.  Fix it before turning it back on.
  1812.  
  1813. all_iter_stmt_with_decl:
  1814.       FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
  1815.       {
  1816. */        /* The value returned by this action is  */
  1817.         /*      1 if everything is OK */ 
  1818.         /*      0 in case of error or already bound iterator */
  1819. /*
  1820.         iterator_for_loop_start ($6);
  1821.       }
  1822.       lineno_labeled_stmt
  1823.       {
  1824.         iterator_for_loop_end ($6);
  1825.         emit_line_note (input_filename, lineno);
  1826.         expand_end_bindings (getdecls (), 1, 0);
  1827.         $<ttype>$ = poplevel (1, 1, 0);
  1828.         if (yychar == CONSTANT || yychar == STRING)
  1829.           pop_momentary_nofree ();
  1830.         else
  1831.           pop_momentary ();        
  1832.       }
  1833. */
  1834.  
  1835. /* Any kind of label, including jump labels and case labels.
  1836.    ANSI C accepts labels only before statements, but we allow them
  1837.    also at the end of a compound statement.  */
  1838.  
  1839. label:      CASE expr_no_commas ':'
  1840.         { register tree value = check_case_value ($2);
  1841.           register tree label
  1842.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1843.  
  1844.           stmt_count++;
  1845.  
  1846.           if (value != error_mark_node)
  1847.             {
  1848.               tree duplicate;
  1849.               int success = pushcase (value, convert_and_check,
  1850.                           label, &duplicate);
  1851.               if (success == 1)
  1852.             error ("case label not within a switch statement");
  1853.               else if (success == 2)
  1854.             {
  1855.               error ("duplicate case value");
  1856.               error_with_decl (duplicate, "this is the first entry for that value");
  1857.             }
  1858.               else if (success == 3)
  1859.             warning ("case value out of range");
  1860.               else if (success == 5)
  1861.             error ("case label within scope of cleanup or variable array");
  1862.             }
  1863.           position_after_white_space (); }
  1864.     | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  1865.         { register tree value1 = check_case_value ($2);
  1866.           register tree value2 = check_case_value ($4);
  1867.           register tree label
  1868.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1869.  
  1870.           stmt_count++;
  1871.  
  1872.           if (value1 != error_mark_node && value2 != error_mark_node)
  1873.             {
  1874.               tree duplicate;
  1875.               int success = pushcase_range (value1, value2,
  1876.                             convert_and_check, label,
  1877.                             &duplicate);
  1878.               if (success == 1)
  1879.             error ("case label not within a switch statement");
  1880.               else if (success == 2)
  1881.             {
  1882.               error ("duplicate case value");
  1883.               error_with_decl (duplicate, "this is the first entry for that value");
  1884.             }
  1885.               else if (success == 3)
  1886.             warning ("case value out of range");
  1887.               else if (success == 4)
  1888.             warning ("empty case range");
  1889.               else if (success == 5)
  1890.             error ("case label within scope of cleanup or variable array");
  1891.             }
  1892.           position_after_white_space (); }
  1893.     | DEFAULT ':'
  1894.         {
  1895.           tree duplicate;
  1896.           register tree label
  1897.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  1898.           int success = pushcase (NULL_TREE, 0, label, &duplicate);
  1899.           stmt_count++;
  1900.           if (success == 1)
  1901.             error ("default label not within a switch statement");
  1902.           else if (success == 2)
  1903.             {
  1904.               error ("multiple default labels in one switch");
  1905.               error_with_decl (duplicate, "this is the first default label");
  1906.             }
  1907.           position_after_white_space (); }
  1908.     | identifier ':'
  1909.         { tree label = define_label (input_filename, lineno, $1);
  1910.           stmt_count++;
  1911.           emit_nop ();
  1912.           if (label)
  1913.             expand_label (label);
  1914.           position_after_white_space (); }
  1915.     ;
  1916.  
  1917. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  1918.  
  1919. maybe_type_qual:
  1920.     /* empty */
  1921.         { emit_line_note (input_filename, lineno);
  1922.           $$ = NULL_TREE; }
  1923.     | TYPE_QUAL
  1924.         { emit_line_note (input_filename, lineno); }
  1925.     ;
  1926.  
  1927. xexpr:
  1928.     /* empty */
  1929.         { $$ = NULL_TREE; }
  1930.     | expr
  1931.     ;
  1932.  
  1933. /* These are the operands other than the first string and colon
  1934.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  1935. asm_operands: /* empty */
  1936.         { $$ = NULL_TREE; }
  1937.     | nonnull_asm_operands
  1938.     ;
  1939.  
  1940. nonnull_asm_operands:
  1941.       asm_operand
  1942.     | nonnull_asm_operands ',' asm_operand
  1943.         { $$ = chainon ($1, $3); }
  1944.     ;
  1945.  
  1946. asm_operand:
  1947.       STRING '(' expr ')'
  1948.         { $$ = build_tree_list ($1, $3); }
  1949.     ;
  1950.  
  1951. asm_clobbers:
  1952.       string
  1953.         { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
  1954.     | asm_clobbers ',' string
  1955.         { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
  1956.     ;
  1957.  
  1958. /* This is what appears inside the parens in a function declarator.
  1959.    Its value is a list of ..._TYPE nodes.  */
  1960. parmlist:
  1961.         { pushlevel (0);
  1962.           clear_parm_order ();
  1963.           declare_parm_level (0); }
  1964.       parmlist_1
  1965.         { $$ = $2;
  1966.           parmlist_tags_warning ();
  1967.           poplevel (0, 0, 0); }
  1968.     ;
  1969.  
  1970. parmlist_1:
  1971.       parmlist_2 ')'
  1972.     | parms ';'
  1973.         { tree parm;
  1974.           if (pedantic)
  1975.             pedwarn ("ANSI C forbids forward parameter declarations");
  1976.           /* Mark the forward decls as such.  */
  1977.           for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  1978.             TREE_ASM_WRITTEN (parm) = 1;
  1979.           clear_parm_order (); }
  1980.       parmlist_1
  1981.         { $$ = $4; }
  1982.     | error ')'
  1983.         { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  1984.     ;
  1985.  
  1986. /* This is what appears inside the parens in a function declarator.
  1987.    Is value is represented in the format that grokdeclarator expects.  */
  1988. parmlist_2:  /* empty */
  1989.         { $$ = get_parm_info (0); }
  1990.     | ELLIPSIS
  1991.         { $$ = get_parm_info (0);
  1992.           /* Gcc used to allow this as an extension.  However, it does
  1993.              not work for all targets, and thus has been disabled.
  1994.              Also, since func (...) and func () are indistinguishable,
  1995.              it caused problems with the code in expand_builtin which
  1996.              tries to verify that BUILT_IN_NEXT_ARG is being used
  1997.              correctly.  */
  1998.           error ("ANSI C requires a named argument before `...'");
  1999.         }
  2000.     | parms
  2001.         { $$ = get_parm_info (1); }
  2002.     | parms ',' ELLIPSIS
  2003.         { $$ = get_parm_info (0); }
  2004.     ;
  2005.  
  2006. parms:
  2007.     parm
  2008.         { push_parm_decl ($1); }
  2009.     | parms ',' parm
  2010.         { push_parm_decl ($3); }
  2011.     ;
  2012.  
  2013. /* A single parameter declaration or parameter type name,
  2014.    as found in a parmlist.  */
  2015. parm:
  2016.       typed_declspecs parm_declarator
  2017.         { $$ = build_tree_list ($1, $2)    ; }
  2018.     | typed_declspecs notype_declarator
  2019.         { $$ = build_tree_list ($1, $2)    ; }
  2020.     | typed_declspecs absdcl
  2021.         { $$ = build_tree_list ($1, $2); }
  2022.     | declmods notype_declarator
  2023.         { $$ = build_tree_list ($1, $2)    ; }
  2024.     | declmods absdcl
  2025.         { $$ = build_tree_list ($1, $2); }
  2026.     ;
  2027.  
  2028. /* This is used in a function definition
  2029.    where either a parmlist or an identifier list is ok.
  2030.    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
  2031. parmlist_or_identifiers:
  2032.         { pushlevel (0);
  2033.           clear_parm_order ();
  2034.           declare_parm_level (1); }
  2035.       parmlist_or_identifiers_1
  2036.         { $$ = $2;
  2037.           parmlist_tags_warning ();
  2038.           poplevel (0, 0, 0); }
  2039.     ;
  2040.  
  2041. parmlist_or_identifiers_1:
  2042.       parmlist_1
  2043.     | identifiers ')'
  2044.         { tree t;
  2045.           for (t = $1; t; t = TREE_CHAIN (t))
  2046.             if (TREE_VALUE (t) == NULL_TREE)
  2047.               error ("`...' in old-style identifier list");
  2048.           $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
  2049.     ;
  2050.  
  2051. /* A nonempty list of identifiers.  */
  2052. identifiers:
  2053.     IDENTIFIER
  2054.         { $$ = build_tree_list (NULL_TREE, $1); }
  2055.     | identifiers ',' IDENTIFIER
  2056.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2057.     ;
  2058.  
  2059. /* A nonempty list of identifiers, including typenames.  */
  2060. identifiers_or_typenames:
  2061.     identifier
  2062.         { $$ = build_tree_list (NULL_TREE, $1); }
  2063.     | identifiers_or_typenames ',' identifier
  2064.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2065.     ;
  2066.  
  2067. /* Objective-C productions.  */
  2068.  
  2069. objcdef:
  2070.       classdef
  2071.     | classdecl
  2072.     | aliasdecl
  2073.     | protocoldef
  2074.     | methoddef
  2075.     | END
  2076.         {
  2077.           if (objc_implementation_context)
  2078.                     {
  2079.               finish_class (objc_implementation_context);
  2080.               objc_ivar_chain = NULL_TREE;
  2081.               objc_implementation_context = NULL_TREE;
  2082.             }
  2083.           else
  2084.             warning ("`@end' must appear in an implementation context");
  2085.         }
  2086.     ;
  2087.  
  2088. /* A nonempty list of identifiers.  */
  2089. identifier_list:
  2090.     identifier
  2091.         { $$ = build_tree_list (NULL_TREE, $1); }
  2092.     | identifier_list ',' identifier
  2093.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2094.     ;
  2095.  
  2096. classdecl:
  2097.       CLASS identifier_list ';'
  2098.         {
  2099.           objc_declare_class ($2);
  2100.         }
  2101.  
  2102. aliasdecl:
  2103.       ALIAS identifier identifier ';'
  2104.         {
  2105.           objc_declare_alias ($2, $3);
  2106.         }
  2107.  
  2108. classdef:
  2109.       INTERFACE identifier protocolrefs '{'
  2110.         {
  2111.           objc_interface_context = objc_ivar_context
  2112.             = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
  2113.                   objc_public_flag = 0;
  2114.         }
  2115.       ivar_decl_list '}'
  2116.         {
  2117.                   continue_class (objc_interface_context);
  2118.         }
  2119.       methodprotolist
  2120.       END
  2121.         {
  2122.           finish_class (objc_interface_context);
  2123.           objc_interface_context = NULL_TREE;
  2124.         }
  2125.  
  2126.     | INTERFACE identifier protocolrefs
  2127.         {
  2128.           objc_interface_context
  2129.             = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
  2130.                   continue_class (objc_interface_context);
  2131.         }
  2132.       methodprotolist
  2133.       END
  2134.         {
  2135.           finish_class (objc_interface_context);
  2136.           objc_interface_context = NULL_TREE;
  2137.         }
  2138.  
  2139.     | INTERFACE identifier ':' identifier protocolrefs '{'
  2140.         {
  2141.           objc_interface_context = objc_ivar_context
  2142.             = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
  2143.                   objc_public_flag = 0;
  2144.         }
  2145.       ivar_decl_list '}'
  2146.         {
  2147.                   continue_class (objc_interface_context);
  2148.         }
  2149.       methodprotolist
  2150.       END
  2151.         {
  2152.           finish_class (objc_interface_context);
  2153.           objc_interface_context = NULL_TREE;
  2154.         }
  2155.  
  2156.     | INTERFACE identifier ':' identifier protocolrefs
  2157.         {
  2158.           objc_interface_context
  2159.             = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
  2160.                   continue_class (objc_interface_context);
  2161.         }
  2162.       methodprotolist
  2163.       END
  2164.         {
  2165.           finish_class (objc_interface_context);
  2166.           objc_interface_context = NULL_TREE;
  2167.         }
  2168.  
  2169.     | IMPLEMENTATION identifier '{'
  2170.         {
  2171.           objc_implementation_context = objc_ivar_context
  2172.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
  2173.                   objc_public_flag = 0;
  2174.         }
  2175.       ivar_decl_list '}'
  2176.         {
  2177.                   objc_ivar_chain
  2178.             = continue_class (objc_implementation_context);
  2179.         }
  2180.  
  2181.     | IMPLEMENTATION identifier
  2182.         {
  2183.           objc_implementation_context
  2184.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
  2185.                   objc_ivar_chain
  2186.             = continue_class (objc_implementation_context);
  2187.         }
  2188.  
  2189.     | IMPLEMENTATION identifier ':' identifier '{'
  2190.         {
  2191.           objc_implementation_context = objc_ivar_context
  2192.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2193.                   objc_public_flag = 0;
  2194.         }
  2195.       ivar_decl_list '}'
  2196.         {
  2197.                   objc_ivar_chain
  2198.             = continue_class (objc_implementation_context);
  2199.         }
  2200.  
  2201.     | IMPLEMENTATION identifier ':' identifier
  2202.         {
  2203.           objc_implementation_context
  2204.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2205.                   objc_ivar_chain
  2206.             = continue_class (objc_implementation_context);
  2207.         }
  2208.  
  2209.     | INTERFACE identifier '(' identifier ')' protocolrefs
  2210.         {
  2211.           objc_interface_context
  2212.             = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
  2213.                   continue_class (objc_interface_context);
  2214.         }
  2215.       methodprotolist
  2216.       END
  2217.         {
  2218.           finish_class (objc_interface_context);
  2219.           objc_interface_context = NULL_TREE;
  2220.         }
  2221.  
  2222.     | IMPLEMENTATION identifier '(' identifier ')'
  2223.         {
  2224.           objc_implementation_context
  2225.             = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2226.                   objc_ivar_chain
  2227.             = continue_class (objc_implementation_context);
  2228.         }
  2229.     ;
  2230.  
  2231. protocoldef:
  2232.       PROTOCOL identifier protocolrefs
  2233.         {
  2234.           remember_protocol_qualifiers ();
  2235.           objc_interface_context
  2236.             = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
  2237.         }
  2238.       methodprotolist END
  2239.         {
  2240.           forget_protocol_qualifiers();
  2241.           finish_protocol(objc_interface_context);
  2242.           objc_interface_context = NULL_TREE;
  2243.         }
  2244.     ;
  2245.  
  2246. protocolrefs:
  2247.       /* empty */
  2248.         {
  2249.           $$ = NULL_TREE;
  2250.         }
  2251.     | ARITHCOMPARE identifier_list ARITHCOMPARE
  2252.         {
  2253.           if ($1 == LT_EXPR && $3 == GT_EXPR)
  2254.             $$ = $2;
  2255.           else
  2256.             YYERROR1;
  2257.         }
  2258.     ;
  2259.  
  2260. ivar_decl_list:
  2261.           ivar_decl_list visibility_spec ivar_decls
  2262.         | ivar_decls
  2263.         ;
  2264.  
  2265. visibility_spec:
  2266.       PRIVATE { objc_public_flag = 2; }
  2267.     | PROTECTED { objc_public_flag = 0; }
  2268.     | PUBLIC { objc_public_flag = 1; }
  2269.     ;
  2270.  
  2271. ivar_decls:
  2272.           /* empty */
  2273.         {
  2274.                   $$ = NULL_TREE;
  2275.                 }
  2276.     | ivar_decls ivar_decl ';'
  2277.     | ivar_decls ';'
  2278.         {
  2279.                   if (pedantic)
  2280.             pedwarn ("extra semicolon in struct or union specified");
  2281.                 }
  2282.     ;
  2283.  
  2284.  
  2285. /* There is a shift-reduce conflict here, because `components' may
  2286.    start with a `typename'.  It happens that shifting (the default resolution)
  2287.    does the right thing, because it treats the `typename' as part of
  2288.    a `typed_typespecs'.
  2289.  
  2290.    It is possible that this same technique would allow the distinction
  2291.    between `notype_initdecls' and `initdecls' to be eliminated.
  2292.    But I am being cautious and not trying it.  */
  2293.  
  2294. ivar_decl:
  2295.     typed_typespecs setspecs ivars
  2296.             {
  2297.                   $$ = $3;
  2298.           resume_momentary ($2);
  2299.                 }
  2300.     | nonempty_type_quals setspecs ivars
  2301.         {
  2302.                   $$ = $3;
  2303.           resume_momentary ($2);
  2304.                 }
  2305.     | error
  2306.         { $$ = NULL_TREE; }
  2307.     ;
  2308.  
  2309. ivars:
  2310.       /* empty */
  2311.         { $$ = NULL_TREE; }
  2312.     | ivar_declarator
  2313.     | ivars ',' ivar_declarator
  2314.     ;
  2315.  
  2316. ivar_declarator:
  2317.       declarator
  2318.         {
  2319.           $$ = add_instance_variable (objc_ivar_context,
  2320.                           objc_public_flag,
  2321.                           $1, current_declspecs,
  2322.                           NULL_TREE);
  2323.                 }
  2324.     | declarator ':' expr_no_commas
  2325.         {
  2326.           $$ = add_instance_variable (objc_ivar_context,
  2327.                           objc_public_flag,
  2328.                           $1, current_declspecs, $3);
  2329.                 }
  2330.     | ':' expr_no_commas
  2331.         {
  2332.           $$ = add_instance_variable (objc_ivar_context,
  2333.                           objc_public_flag,
  2334.                           NULL_TREE,
  2335.                           current_declspecs, $2);
  2336.                 }
  2337.     ;
  2338.  
  2339. methoddef:
  2340.       '+'
  2341.         {
  2342.           remember_protocol_qualifiers ();
  2343.           if (objc_implementation_context)
  2344.             objc_inherit_code = CLASS_METHOD_DECL;
  2345.                   else
  2346.             fatal ("method definition not in class context");
  2347.         }
  2348.       methoddecl
  2349.         {
  2350.           forget_protocol_qualifiers ();
  2351.           add_class_method (objc_implementation_context, $3);
  2352.           start_method_def ($3);
  2353.           objc_method_context = $3;
  2354.         }
  2355.       optarglist
  2356.         {
  2357.           continue_method_def ();
  2358.         }
  2359.       compstmt_or_error
  2360.         {
  2361.           finish_method_def ();
  2362.           objc_method_context = NULL_TREE;
  2363.         }
  2364.  
  2365.     | '-'
  2366.         {
  2367.           remember_protocol_qualifiers ();
  2368.           if (objc_implementation_context)
  2369.             objc_inherit_code = INSTANCE_METHOD_DECL;
  2370.                   else
  2371.             fatal ("method definition not in class context");
  2372.         }
  2373.       methoddecl
  2374.         {
  2375.           forget_protocol_qualifiers ();
  2376.           add_instance_method (objc_implementation_context, $3);
  2377.           start_method_def ($3);
  2378.           objc_method_context = $3;
  2379.         }
  2380.       optarglist
  2381.         {
  2382.           continue_method_def ();
  2383.         }
  2384.       compstmt_or_error
  2385.         {
  2386.           finish_method_def ();
  2387.           objc_method_context = NULL_TREE;
  2388.         }
  2389.     ;
  2390.  
  2391. /* the reason for the strange actions in this rule
  2392.  is so that notype_initdecls when reached via datadef
  2393.  can find a valid list of type and sc specs in $0. */
  2394.  
  2395. methodprotolist:
  2396.       /* empty  */
  2397.     | {$<ttype>$ = NULL_TREE; } methodprotolist2
  2398.     ;
  2399.  
  2400. methodprotolist2:         /* eliminates a shift/reduce conflict */
  2401.        methodproto
  2402.     |  datadef
  2403.     | methodprotolist2 methodproto
  2404.     | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
  2405.     ;
  2406.  
  2407. semi_or_error:
  2408.       ';'
  2409.     | error
  2410.     ;
  2411.  
  2412. methodproto:
  2413.       '+'
  2414.         {
  2415.           objc_inherit_code = CLASS_METHOD_DECL;
  2416.         }
  2417.       methoddecl
  2418.         {
  2419.           add_class_method (objc_interface_context, $3);
  2420.         }
  2421.       semi_or_error
  2422.  
  2423.     | '-'
  2424.         {
  2425.           objc_inherit_code = INSTANCE_METHOD_DECL;
  2426.         }
  2427.       methoddecl
  2428.         {
  2429.           add_instance_method (objc_interface_context, $3);
  2430.         }
  2431.       semi_or_error
  2432.     ;
  2433.  
  2434. methoddecl:
  2435.       '(' typename ')' unaryselector
  2436.         {
  2437.           $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE);
  2438.         }
  2439.  
  2440.     | unaryselector
  2441.         {
  2442.           $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE);
  2443.         }
  2444.  
  2445.     | '(' typename ')' keywordselector optparmlist
  2446.         {
  2447.           $$ = build_method_decl (objc_inherit_code, $2, $4, $5);
  2448.         }
  2449.  
  2450.     | keywordselector optparmlist
  2451.         {
  2452.           $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2);
  2453.         }
  2454.     ;
  2455.  
  2456. /* "optarglist" assumes that start_method_def has already been called...
  2457.    if it is not, the "xdecls" will not be placed in the proper scope */
  2458.  
  2459. optarglist:
  2460.       /* empty */
  2461.     | ';' myxdecls
  2462.     ;
  2463.  
  2464. /* to get around the following situation: "int foo (int a) int b; {}" that
  2465.    is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
  2466.  
  2467. myxdecls:
  2468.       /* empty */
  2469.     | mydecls
  2470.     ;
  2471.  
  2472. mydecls:
  2473.     mydecl
  2474.     | errstmt
  2475.     | mydecls mydecl
  2476.     | mydecl errstmt
  2477.     ;
  2478.  
  2479. mydecl:
  2480.     typed_declspecs setspecs myparms ';'
  2481.         { resume_momentary ($2); }
  2482.     | typed_declspecs ';'
  2483.         { shadow_tag ($1); }
  2484.     | declmods ';'
  2485.         { pedwarn ("empty declaration"); }
  2486.     ;
  2487.  
  2488. myparms:
  2489.     myparm
  2490.         { push_parm_decl ($1); }
  2491.     | myparms ',' myparm
  2492.         { push_parm_decl ($3); }
  2493.     ;
  2494.  
  2495. /* A single parameter declaration or parameter type name,
  2496.    as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
  2497.  
  2498. myparm:
  2499.       parm_declarator
  2500.         { $$ = build_tree_list (current_declspecs, $1)    ; }
  2501.     | notype_declarator
  2502.         { $$ = build_tree_list (current_declspecs, $1)    ; }
  2503.     | absdcl
  2504.         { $$ = build_tree_list (current_declspecs, $1)    ; }
  2505.     ;
  2506.  
  2507. optparmlist:
  2508.       /* empty */
  2509.         {
  2510.               $$ = NULL_TREE;
  2511.         }
  2512.     | ',' ELLIPSIS
  2513.         {
  2514.           /* oh what a kludge! */
  2515.           $$ = (tree)1;
  2516.         }
  2517.     | ','
  2518.         {
  2519.           pushlevel (0);
  2520.         }
  2521.       parmlist_2
  2522.         {
  2523.             /* returns a tree list node generated by get_parm_info */
  2524.           $$ = $3;
  2525.           poplevel (0, 0, 0);
  2526.         }
  2527.     ;
  2528.  
  2529. unaryselector:
  2530.       selector
  2531.     ;
  2532.  
  2533. keywordselector:
  2534.       keyworddecl
  2535.  
  2536.     | keywordselector keyworddecl
  2537.         {
  2538.           $$ = chainon ($1, $2);
  2539.         }
  2540.     ;
  2541.  
  2542. selector:
  2543.       IDENTIFIER
  2544.         | TYPENAME
  2545.       | OBJECTNAME
  2546.     | reservedwords
  2547.     ;
  2548.  
  2549. reservedwords:
  2550.       ENUM { $$ = get_identifier (token_buffer); }
  2551.     | STRUCT { $$ = get_identifier (token_buffer); }
  2552.     | UNION { $$ = get_identifier (token_buffer); }
  2553.     | IF { $$ = get_identifier (token_buffer); }
  2554.     | ELSE { $$ = get_identifier (token_buffer); }
  2555.     | WHILE { $$ = get_identifier (token_buffer); }
  2556.     | DO { $$ = get_identifier (token_buffer); }
  2557.     | FOR { $$ = get_identifier (token_buffer); }
  2558.     | SWITCH { $$ = get_identifier (token_buffer); }
  2559.     | CASE { $$ = get_identifier (token_buffer); }
  2560.     | DEFAULT { $$ = get_identifier (token_buffer); }
  2561.     | BREAK { $$ = get_identifier (token_buffer); }
  2562.     | CONTINUE { $$ = get_identifier (token_buffer); }
  2563.     | RETURN  { $$ = get_identifier (token_buffer); }
  2564.     | GOTO { $$ = get_identifier (token_buffer); }
  2565.     | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
  2566.         | SIZEOF { $$ = get_identifier (token_buffer); }
  2567.     | TYPEOF { $$ = get_identifier (token_buffer); }
  2568.     | ALIGNOF { $$ = get_identifier (token_buffer); }
  2569.     | TYPESPEC | TYPE_QUAL
  2570.     ;
  2571.  
  2572. keyworddecl:
  2573.       selector ':' '(' typename ')' identifier
  2574.         {
  2575.           $$ = build_keyword_decl ($1, $4, $6);
  2576.         }
  2577.  
  2578.     | selector ':' identifier
  2579.         {
  2580.           $$ = build_keyword_decl ($1, NULL_TREE, $3);
  2581.         }
  2582.  
  2583.     | ':' '(' typename ')' identifier
  2584.         {
  2585.           $$ = build_keyword_decl (NULL_TREE, $3, $5);
  2586.         }
  2587.  
  2588.     | ':' identifier
  2589.         {
  2590.           $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
  2591.         }
  2592.     ;
  2593.  
  2594. messageargs:
  2595.       selector
  2596.         | keywordarglist
  2597.     ;
  2598.  
  2599. keywordarglist:
  2600.       keywordarg
  2601.     | keywordarglist keywordarg
  2602.         {
  2603.           $$ = chainon ($1, $2);
  2604.         }
  2605.     ;
  2606.  
  2607.  
  2608. keywordexpr:
  2609.       nonnull_exprlist
  2610.         {
  2611.           if (TREE_CHAIN ($1) == NULL_TREE)
  2612.             /* just return the expr., remove a level of indirection */
  2613.             $$ = TREE_VALUE ($1);
  2614.                   else
  2615.             /* we have a comma expr., we will collapse later */
  2616.             $$ = $1;
  2617.         }
  2618.     ;
  2619.  
  2620. keywordarg:
  2621.       selector ':' keywordexpr
  2622.         {
  2623.           $$ = build_tree_list ($1, $3);
  2624.         }
  2625.     | ':' keywordexpr
  2626.         {
  2627.           $$ = build_tree_list (NULL_TREE, $2);
  2628.         }
  2629.     ;
  2630.  
  2631. receiver:
  2632.       expr
  2633.     | CLASSNAME
  2634.         {
  2635.           $$ = get_class_reference ($1);
  2636.         }
  2637.     ;
  2638.  
  2639. objcmessageexpr:
  2640.       '['
  2641.         { objc_receiver_context = 1; }
  2642.       receiver
  2643.         { objc_receiver_context = 0; }
  2644.       messageargs ']'
  2645.         {
  2646.           $$ = build_tree_list ($3, $5);
  2647.         }
  2648.     ;
  2649.  
  2650. selectorarg:
  2651.       selector
  2652.         | keywordnamelist
  2653.     ;
  2654.  
  2655. keywordnamelist:
  2656.       keywordname
  2657.     | keywordnamelist keywordname
  2658.         {
  2659.           $$ = chainon ($1, $2);
  2660.         }
  2661.     ;
  2662.  
  2663. keywordname:
  2664.       selector ':'
  2665.         {
  2666.           $$ = build_tree_list ($1, NULL_TREE);
  2667.         }
  2668.     | ':'
  2669.         {
  2670.           $$ = build_tree_list (NULL_TREE, NULL_TREE);
  2671.         }
  2672.     ;
  2673.  
  2674. objcselectorexpr:
  2675.       SELECTOR '(' selectorarg ')'
  2676.         {
  2677.           $$ = $3;
  2678.         }
  2679.     ;
  2680.  
  2681. objcprotocolexpr:
  2682.       PROTOCOL '(' identifier ')'
  2683.         {
  2684.           $$ = $3;
  2685.         }
  2686.     ;
  2687.  
  2688. /* extension to support C-structures in the archiver */
  2689.  
  2690. objcencodeexpr:
  2691.       ENCODE '(' typename ')'
  2692.         {
  2693.           $$ = groktypename ($3);
  2694.         }
  2695.     ;
  2696.  
  2697. %%
  2698.